package com.li.net;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.util.concurrent.Callable;

public class SocketCallable implements Callable<Void>{

	private Socket socket;
	
	public SocketCallable(Socket socket){
		this.socket=socket;
	}
	public Void call() throws Exception {
		InputStream is=socket.getInputStream();
		BufferedReader br=new BufferedReader(new InputStreamReader(is));
		char[] data=new char[1024];
		while(br.read(data)!=-1){
			System.out.println(data);
		}
		OutputStream os=socket.getOutputStream();
		BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(os));
		bw.write("i am received");
		bw.flush();
		socket.close();
		return null;
	}

}
